package com.dctp.common.db;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;

public class FxRateDb {
    public static Record findById(Long id) {
        return Db.findFirst("SELECT * FROM dctp_fx_rate WHERE id = ?", id);
    }
    public static Record findByCode(String code) {
        return Db.findFirst("SELECT * FROM dctp_fx_rate WHERE code = ?", code);
    }
    public static Record findByCodeAndTarget(String code, String targetCode) {
        return Db.findFirst("SELECT * FROM dctp_fx_rate WHERE code = ? AND target_code = ?", code, targetCode);
    }
    public static void update(Long id, Record fxRate) {
        Db.update("dctp_fx_rate", "id", fxRate);
    }
    public static void delete(Long id) {
        Db.update("DELETE FROM dctp_fx_rate WHERE id = ?", id);
    }
}
